<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of vdsmask_full</title>
  <meta name="keywords" content="vdsmask_full">
  <meta name="description" content="Inputs">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../../index.html">Home</a> &gt;  <a href="../../index.html">CO4OI</a> &gt; <a href="../index.html">misc</a> &gt; <a href="index.html">vds_sampling</a> &gt; vdsmask_full.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../../index.html"><img alt="<" border="0" src="../../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for CO4OI/misc/vds_sampling&nbsp;<img alt=">" border="0" src="../../../right.png"></a></td></tr></table>-->

<h1>vdsmask_full
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="box"><strong>Inputs</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="box"><strong>function [mask]=vdsmask_full(N,M,p) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="fragment"><pre class="comment">Inputs
N and M: Size of mask
p: Coverage percentage
d: Shape parameter that controls the density samplig</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../../matlabicon.gif)">
<li><a href="genMask.html" class="code" title="function mask = genMask(pdf, seed)">genMask</a>	GENMASK - Generate a mask with variable density sampling</li><li><a href="modifyPDF.html" class="code" title="function [new_pdf, alpha] = modifyPDF(pdf, nb_meas)">modifyPDF</a>	Check PDF and normalize it</li></ul>
This function is called by:
<ul style="list-style-image:url(../../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [mask]=vdsmask_full(N,M,p)</a>
0002 
0003 <span class="comment">%Inputs</span>
0004 <span class="comment">%N and M: Size of mask</span>
0005 <span class="comment">%p: Coverage percentage</span>
0006 <span class="comment">%d: Shape parameter that controls the density samplig</span>
0007 
0008 nb_meas=round(p*N*M);
0009 tol=ceil(p*N*M)-floor(p*N*M);
0010 d=1;
0011 
0012 
0013 [x,y] = meshgrid(linspace(-1, 1, M), linspace(-1, 1, N)); <span class="comment">% Cartesian grid</span>
0014 r = sqrt(x.^2+y.^2); r = r/max(r(:)); <span class="comment">% Polar grid</span>
0015 
0016 alpha=-1;
0017 it=0;
0018 maxit=20;
0019 <span class="keyword">while</span> (alpha&lt;-0.01 || alpha&gt;0.01) &amp;&amp; it&lt;maxit
0020     pdf = (1-r).^d;
0021     [new_pdf,alpha] = <a href="modifyPDF.html" class="code" title="function [new_pdf, alpha] = modifyPDF(pdf, nb_meas)">modifyPDF</a>(pdf, nb_meas);
0022     <span class="keyword">if</span> alpha&lt;0
0023         d=d+0.1;
0024     <span class="keyword">else</span>
0025         d=d-0.1;
0026     <span class="keyword">end</span>
0027     it=it+1;
0028 <span class="keyword">end</span>
0029 
0030 
0031 
0032 mask = zeros(size(new_pdf));
0033 <span class="keyword">while</span> sum(mask(:))&gt;nb_meas+tol || sum(mask(:))&lt;nb_meas-tol
0034     mask = <a href="genMask.html" class="code" title="function mask = genMask(pdf, seed)">genMask</a>(new_pdf);
0035 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Thu 18-Jul-2013 19:25:15 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>